<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <div id="app">
        <h1>{{msg}}</h1>
        <input type="text" placeholder="请输入关键词" v-model="keyword">
        <table>
            <tr>
                <th>序号</th>
                <th>英雄</th>
                <th>能力值</th>
                <th>选择</th>
            </tr>
            <tr v-for="(hero,index) of herosArr" :key="hero.id">
                <td>{{index+1}}</td>
                <td>{{hero.name}}</td>
                <td>{{hero.power}}</td>
                <td><input type="checkbox"></td>
            </tr>
        </table>
    </div>
    <script src="js/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                keyword: '',
                msg: '列表过滤',
                heros: [
                    { id: '101', name: '1', power: 10000 },
                    { id: '102', name: '2', power: 93000 },
                    { id: '103', name: '3', power: 82000 },
                    { id: '104', name: '4', power: 7000 },
                ]
            },
            computed: {
                herosArr() {
                    return this.heros.filter((item) => {
                        return item.name.indexOf(this.keyword) >= 0
                    })
                }
            }
        })
    </script>
</body>

</html>